package com.is416;

import android.app.Activity;
//import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.os.Bundle;
import android.widget.TextView;

public class launcher extends Activity {
    /** Called when the activity is first created. */
    @Override
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setTitle("FoodLover");
        setContentView(R.layout.main);
        Button button = (Button)findViewById(R.id.widget72);
        button.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				goToMainMenu();
			}
        	
        });
    }        
    public void goToMainMenu() {
    		/*// TODO Auto-generated method stub
    	Button button = (Button)findViewById(R.id.widget72);
        button.setOnClickListener(new OnClickListener() {
*/
	//	@Override
	//	public void onClick(View v) {
			// TODO Auto-generated method stub
        	setContentView(R.layout.menu);
			Button search_button = (Button)findViewById(R.id.widget59);
			//Button directions_button = (Button)findViewById(R.id.widget60);
			//Button favourites_button = (Button)findViewById(R.id.widget61);
			//Button myprofile_button = (Button)findViewById(R.id.widget62);
			
			search_button.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					setContentView(R.layout.menu_search);
					goToMenuSearch();
				}
				
			});
		/*	directions_button.setOnClickListener(this);
			favourites_button.setOnClickListener(this);
			myprofile_button.setOnClickListener(this);		
			
			switch (v.getId()) {
			case R.id.widget59:
				
				
				break;
				
			case R.id.widget60:
				//setContentView(R.layout.menu_search);
				break;
				
			case R.id.widget61:
				break;
				
			case R.id.widget62:
				break;		
			}*/
		}
		public void goToMenuSearch() {
			
			// TODO Auto-generated method stub
			Button searchfood = (Button)findViewById(R.id.widget59_food);
			Button searchfriends = (Button)findViewById(R.id.widget60_friends);
			Button backMainMenu = (Button)findViewById(R.id.widget61_back);
						
			searchfood.setOnClickListener(new OnClickListener(){
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					setContentView(R.layout.search_food);
					goToSearchFoodMenu();
					
				}

				public void goToSearchFoodMenu() {
					// TODO Auto-generated method stub
					Button search_food_type = (Button)findViewById(R.id.widget59_type);
					Button search_food_budget = (Button)findViewById(R.id.widget60_budget);
					Button search_food_area = (Button)findViewById(R.id.widget61_area);
					Button search_food_all = (Button)findViewById(R.id.widget63_all);
					Button search_food_back = (Button)findViewById(R.id.widget65_back);
					
					search_food_type.setOnClickListener(new OnClickListener(){
						@Override
						public void onClick(View v) {
							// TODO Auto-generated method stub
							setContentView(R.layout.search_food_type);
							goToSearchFoodType();
							
						}
						public void goToSearchFoodType() {
							// TODO Auto-generated method stub
							Button back = (Button)findViewById(R.id.widget122);
							back.setOnClickListener(new OnClickListener(){
								@Override
								public void onClick(View v) {												
									// TODO Auto-generated method stub
									setContentView(R.layout.search_food);
									goToSearchFoodMenu();
									return;
								}
							});
						}				
					});
					
					
					search_food_budget.setOnClickListener(new OnClickListener(){
						
						@Override
						public void onClick(View v) {
							// TODO Auto-generated method stub
							setContentView(R.layout.search_food_budget);
							goToSearchFoodBudget();
							
						}

						public void goToSearchFoodBudget() {
							// TODO Auto-generated method stub
							Button back = (Button)findViewById(R.id.widget114);
							back.setOnClickListener(new OnClickListener()
							{
								@Override
								public void onClick(View v) {
									// TODO Auto-generated method stub
									setContentView(R.layout.search_food);
									goToSearchFoodMenu();
									return;
								}
							});
						}
					});	
					search_food_area.setOnClickListener(new OnClickListener(){

						@Override
						public void onClick(View v) {
							// TODO Auto-generated method stub
							setContentView(R.layout.search_food_area);
							goToSearchFoodArea();
							
						}

						public void goToSearchFoodArea() {
							// TODO Auto-generated method stub
							Button back = (Button)findViewById(R.id.widget106);
							back.setOnClickListener(new OnClickListener()
							{
								@Override
								public void onClick(View v) {
									// TODO Auto-generated method stub
									setContentView(R.layout.search_food);
									goToSearchFoodMenu();
									return;
								}
							});
						}
					});
					search_food_all.setOnClickListener(new OnClickListener(){

						@Override
						public void onClick(View v) {
							// TODO Auto-generated method stub
							setContentView(R.layout.search_all);
							goToSearchFoodAll();
							
						}

						private void goToSearchFoodAll() {
							// TODO Auto-generated method stub
							Button back = (Button)findViewById(R.id.widget98);
							back.setOnClickListener(new OnClickListener()
							{
								@Override
								public void onClick(View v) {
									// TODO Auto-generated method stub
									setContentView(R.layout.search_food);
									goToSearchFoodMenu();
									return;
								}
							});
							
						}
					});
					search_food_back.setOnClickListener(new OnClickListener(){
						@Override
						public void onClick(View v) {
							// TODO Auto-generated method stub
							setContentView(R.layout.menu_search);
							goToMenuSearch();
							return;
						}				
					});
						
					}	
			});
			
			searchfriends.setOnClickListener(new OnClickListener()
			{
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					//setContentView(R.layout.search_food_budget);
				}
			});
			
			backMainMenu.setOnClickListener(new OnClickListener()
			{
				
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					setContentView(R.layout.menu);
					//System.out.print("TEST BACK ON CLICK");
					goToMainMenu();
					return;
				}

				
			});
		}
       
    }

